package com.zhaokuo.code;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class QRecodeDecoderServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/octet-stream");
		String code=request.getParameter("codes");
		String fileName="1340947174608.png";
		String imgPath = request.getRealPath("/img/decoder/"+fileName);
		QRCodeEncoderHandler.encoderQRCode(code, imgPath);
		response.setHeader("Content-Disposition", "attachment;filename=\""
				+ fileName + "\"");
		request.getRequestDispatcher("/img/decoder/"+fileName).forward(request, response);
	}

}
